// Text of project PeriodicElements written on 11/21/95 at 4:01 PM
// Beginning of file PeriodicElements Layout

// Before Script for "myapp"
// Copyright  1995 by Apple Computer, Inc.  All rights reserved.


myapp :=
    {title: "PeriodicElements",
     viewBounds: {left: 0, top: 10, right: 220, bottom: 245},
     viewFormat: 83951953,
     AlarmsEnabled:
       func()
       	begin
       		true; // alarms will always be enabled.
       	end,
     PeriodicAlarm:
       func(alarm)
       	begin
       		write("PeriodicElements Alarm called: ");
       		print(alarm);
       		
       		// ensure we are open (only needed if there is an app user interface for the alarm
       		// or the alarms behavior is implemented by views which must be open
       		if not Visible(self) then
       			:Open();
       		
       		:SysBeep();
       		:SysBeep();
       		:SysBeep();
       		
       		SetValue(lastReported, 'text, "Last Alarm:" && DateNTime(Time()));
       		// we will be automatically called the next time
       	end,
     myEditor:
       // holds a reference to editor view (so we can close in viewQuitScript)
       ,
     viewQuitScript:
       // must return the value of inherited:?viewQuitScript();
       func()
       begin
       	if myEditor then
       		begin
       			myEditor:Close();
       			myEditor := nil;
       		end;
       	inherited:?viewQuitScript();		// this method is defined internally
       end,
     debug: "myapp",
     _proto: @157
    };

editAlarms :=
    {
     buttonClickScript:
       func()
       	begin
       		local editor := {
       			_proto: protoPeriodicAlarmEditor,
       			ownerName: kAppName,					// do not translate
       			ownerSymbol: kAppSymbol,
       			title: "Auto Beep",
       			viewQuitScript: func() SetValue(base, 'myEditor, nil),	// nil out myEditor slot
       		};
       	
       		// we need to keep track of the opened editor view, so we can close it when
       		// our app closes.  So use a slot in the base view ('myEditor) to track it.
       		if not myEditor then
       			myEditor := BuildContext(editor);
       		myEditor:Open();
       	end,
     text: "Auto Beep Editor",
     viewBounds: {left: 58, top: 34, right: 166, bottom: 54},
     debug: "editAlarms",
     _proto: @226
    };
AddStepForm(myapp, editAlarms);



currentDate :=
    {text: "Static Text",
     viewBounds: {left: 24, top: 128, right: 192, bottom: 152},
     viewSetupDoneScript:
       func()
       begin
       :SetupIdle(1); // start our idle routine
       end,
     viewIdleScript:
       func()
       	begin
       		// This is a fairly ugly way to display the time in seconds.  However, you usually do
       		// not want to be displaying the time in seconds anyway... but for this sample it is handy.
       		SetValue(self, 'text, "It is now" && DateNTime(time()) && $( & TimeInSeconds() mod 60 & $) );
       		
       		500;	// Return the number of milliseconds to delay or nil to end idling.
       	end,
     viewJustify: 8388610,
     debug: "currentDate",
     _proto: @218
    };
AddStepForm(myapp, currentDate);



lastReported :=
    {text: "<no alarms reported>",
     viewBounds: {left: 8, top: 64, right: 216, bottom: 88},
     debug: "lastReported",
     _proto: @218
    };
AddStepForm(myapp, lastReported);
StepDeclare(myapp, lastReported, 'lastReported);



jumpBack :=
    {
     buttonClickScript:
       func()
       	begin
       		SetTime(time() - 60 * 24);
       	end,
     text: "Jump -1 Day",
     viewBounds: {left: 18, top: 162, right: 102, bottom: 182},
     debug: "jumpBack",
     _proto: @226
    };
AddStepForm(myapp, jumpBack);



jumpForward :=
    {
     buttonClickScript:
       func()
       	begin
       		SetTime(time() + 60 * 24);
       	end,
     text: "Jump 1 Day",
     viewBounds: {left: 122, top: 162, right: 206, bottom: 182},
     debug: "jumpForward",
     _proto: @226
    };
AddStepForm(myapp, jumpForward);



jumpBackMinute :=
    {
     buttonClickScript:
       func()
       	begin
       		SetTime(time() - 1);
       	end,
     text: "Jump -1 Minute",
     viewBounds: {left: 18, top: 192, right: 102, bottom: 212},
     debug: "jumpBackMinute",
     _proto: @226
    };
AddStepForm(myapp, jumpBackMinute);



jumpForwardMinute :=
    {
     buttonClickScript:
       func()
       	begin
       		SetTime(time() + 1);
       	end,
     text: "Jump 1 Minute",
     viewBounds: {left: 122, top: 192, right: 206, bottom: 212},
     debug: "jumpForwardMinute",
     _proto: @226
    };
AddStepForm(myapp, jumpForwardMinute);




constant |layout_PeriodicElements Layout| := myapp;
// End of file PeriodicElements Layout



